<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>知识库
            <small>疾病库</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>知识库</el-breadcrumb-item>
            <el-breadcrumb-item>疾病库</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <!--v-model="pagination.queryString" 双向绑定了 下面pagination.queryString变量-->
                <el-input placeholder="疾病名称" v-model="pagination.queryString" style="width: 200px;" class="filter-item"></el-input>
                <el-button @click="findPageWithInfo()" class="dalfBut">查询</el-button>
                <el-button type="primary" class="butT" @click="handleCreate()">新建</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>

                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="code" label="项目编码" align="center"></el-table-column>
                <el-table-column prop="nameOfDisease" label="疾病名称" align="center"></el-table-column>
                <el-table-column prop="visitingDepartment" label="就诊科室" align="center"></el-table-column>
                <el-table-column prop="warningLevel" label="预警等级" align="center"></el-table-column>
                <el-table-column prop="visitingTimeLimit" label="就医期限" align="center"></el-table-column>


                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <!--为分页条组件绑定current-change事件，此事件是分页条组件自己定义的事件，当页码改变时触发，对
                    应的处理函数为handleCurrentChang-->

                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
            <!-- 新增标签弹层 -->
            <div class="add-form">
                <el-dialog title="新增运动项目库" :visible.sync="dialogFormVisible">
                    <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right" label-width="100px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="项目编码" prop="code">
                                    <el-input v-model="formData.code"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="疾病名称" prop="nameOfDisease">
                                    <el-input v-model="formData.nameOfDisease"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="异常类型">
                                    <el-select v-model="formData.type">
                                        <el-option label="系统自带" value="0"></el-option>
                                        <el-option label="自定义" value="1"></el-option>

                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="是否职业病">
                                    <el-select v-model="formData.occupational">
                                        <el-option label="是" value="0"></el-option>
                                        <el-option label="否" value="1"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="适用性别">
                                    <el-select v-model="formData.gender">
                                        <el-option label="不限" value="0"></el-option>
                                        <el-option label="女" value="1"></el-option>
                                        <el-option label="男" value="1"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="就医期限">
                                    <el-select v-model="formData.visitingTimeLimit">
                                        <el-option label="立即" value="0"></el-option>
                                        <el-option label="一年内" value="1"></el-option>
                                        <el-option label="半年内" value="1"></el-option>
                                        <el-option label="三个月内" value="1"></el-option>
                                        <el-option label="一个月内" value="1"></el-option>
                                        <el-option label="一周内" value="1"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="就诊科室">
                                    <el-select v-model="formData.visitingDepartment">
                                        <el-option label="内科" value="内科"></el-option>
                                        <el-option label="外科" value="外科"></el-option>
                                        <el-option label="妇产科" value="妇产科"></el-option>
                                        <el-option label="男科" value="男科"></el-option>
                                        <el-option label="五官科" value="五官科"></el-option>
                                        <el-option label="皮肤性病科" value="皮肤性病科"></el-option>
                                        <el-option label="中医科" value="中医科"></el-option>
                                        <el-option label="传染科" value="传染科"></el-option>
                                        <el-option label="精神心理科" value="精神心理科"></el-option>
                                        <el-option label="神经内科" value="神经内科"></el-option>
                                        <el-option label="呼吸内裤" value="呼吸内科"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="预警等级">
                                    <el-select v-model="formData.warningLevel">
                                        <el-option label="0星" value="0星"></el-option>
                                        <el-option label="1星" value="1星"></el-option>
                                        <el-option label="2星" value="2星"></el-option>
                                        <el-option label="3星" value="3星"></el-option>
                                        <el-option label="4星" value="4星"></el-option>
                                        <el-option label="5星" value="5星"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="其他名称">
                                    <el-input v-model="formData.otherName" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="医学解释">
                                    <el-input v-model="formData.medicalExplanation" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="常见原因">
                                    <el-input v-model="formData.commonCauses" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="建议">
                                    <el-input v-model="formData.advice" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false">取消</el-button>
                        <el-button type="primary" @click="handleAdd()">确定</el-button>
                    </div>
                </el-dialog>
            </div>
            <!-- 编辑标签弹层 -->
            <div class="add-form">
                <el-dialog title="新增运动项目库" :visible.sync="dialogFormVisible4Edit">
                    <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right" label-width="100px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="项目编码" prop="code">
                                    <el-input v-model="formData.code"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="疾病名称" prop="nameOfDisease">
                                    <el-input v-model="formData.nameOfDisease"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="异常类型">
                                    <el-select v-model="formData.type">
                                        <el-option label="系统自带" value="0"></el-option>
                                        <el-option label="自定义" value="1"></el-option>

                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="是否职业病">
                                    <el-select v-model="formData.occupational">
                                        <el-option label="是" value="0"></el-option>
                                        <el-option label="否" value="1"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="适用性别">
                                    <el-select v-model="formData.gender">
                                        <el-option label="不限" value="0"></el-option>
                                        <el-option label="女" value="1"></el-option>
                                        <el-option label="男" value="1"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="就医期限">
                                    <el-select v-model="formData.visitingTimeLimit">
                                        <el-option label="立即" value="0"></el-option>
                                        <el-option label="一年内" value="1"></el-option>
                                        <el-option label="半年内" value="1"></el-option>
                                        <el-option label="三个月内" value="1"></el-option>
                                        <el-option label="一个月内" value="1"></el-option>
                                        <el-option label="一周内" value="1"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="就诊科室">
                                    <el-select v-model="formData.visitingDepartment">


                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="预警等级">
                                    <el-select v-model="formData.warningLevel">
                                        <el-option label="0星" value="0星"></el-option>
                                        <el-option label="1星" value="1星"></el-option>
                                        <el-option label="2星" value="2星"></el-option>
                                        <el-option label="3星" value="3星"></el-option>
                                        <el-option label="4星" value="4星"></el-option>
                                        <el-option label="5星" value="5星"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="其他名称">
                                    <el-input v-model="formData.otherName" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="医学解释">
                                    <el-input v-model="formData.medicalExplanation" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="常见原因">
                                    <el-input v-model="formData.commonCauses" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="建议">
                                    <el-input v-model="formData.advice" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">取消</el-button>
                        <el-button type="primary" @click="handleEdit()">确定</el-button>
                    </div>
                </el-dialog>
            </div>

        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>


<script>
    var vue = new Vue({
        el: '#app',
        data: {
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize: 10,//每页显示的记录数
                total: 0,//总记录数
                queryString: null//查询条件
                /* queryString:null//查询条件 双向绑定了  输入框的内容*/
            },
            dataList: [],//当前页要展示的分页列表数据
            formData: {},//表单数据
            dialogFormVisible: false,//增加表单是否可见
            dialogFormVisible4Edit: false,//编辑表单是否可见
            rules: {//校验规则
                number: [{required: true, message: '项目编码为必填项', trigger: 'blur'}],
                name: [{required: true, message: '项目名称为必填项', trigger: 'blur'}]
            }
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.findPage();
        },
        methods: {
            //权限不足提示
            showMessage(r) {
                if (r == 'Error: Request failed with status code 403') { //权限不足
                    this.$message.error('无访问权限');
                    return;
                } else {
                    this.$message.error('未知错误');
                    return;
                }
            },

            //查询功能
            findPageWithInfo() {
                this.pagination.currentPage = 1;
                this.findPage();
            },
            //分页查询检查项展示页面
            findPage() {
                var param = {
                    currentPage: this.pagination.currentPage,
                    pageSize: this.pagination.pageSize,
                    queryString: this.pagination.queryString
                };
                axios.post("/ill/getPage.do", param).then((res) => {
                    this.dataList = res.data.rows;
                    this.pagination.total = res.data.total;
                });
            },

            /*当用户点击查询按钮改变当前页码值,并调用findPage方法*/
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPage();
            },

            //编辑提交
            handleEdit() {
                axios.post("/ill/edit.do", this.formData).then((res) => {
                    //失败
                    if (!res.data.flag) {
                        this.$message.error(res.data.message);
                        return false;
                    }
                    //添加成功
                    this.$message({
                        message: res.data.message,
                        type: 'success'
                    });
                    this.findPage();
                    this.dialogFormVisible4Edit = false;
                })
            },
            //添加
            handleAdd() {
                axios.post("/ill/addIll.do", this.formData).then((res) => {
                    //失败
                    if (!res.data.flag) {
                        this.$message.error(res.data.message);
                        return false;
                    }
                    //添加成功
                    this.$message({
                        message: res.data.message,
                        type: 'success'
                    });
                    this.findPage();
                    this.dialogFormVisible = false;
                })
            },

            // 重置表单
            resetForm() {
                this.formData = {};
            },
            // 弹出添加窗口
            handleCreate() {
                this.dialogFormVisible = true;
                this.resetForm();
            },
            // 弹出编辑窗口
            handleUpdate(row) {
                this.dialogFormVisible4Edit = true;
                axios.post("/ill/findSportById.do?id=" + row.id).then((res) => {
                    if (!res.data.flag) {
                        this.$message.error(res.data.message);
                        return false;
                    }
                    this.formData = res.data.data;
                })
            },
            // 删除
            handleDelete(row) {
                this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.post("/ill/deleteById.do?id=" + row.id).then((res) => {
                        if (res.data.flag) {
                            this.$message({
                                message: res.data.message,
                                type: 'success'
                            })

                        } else {
                            this.$message.error(res.data.message);
                        }
                        this.findPage()
                    });
                    this.$message({
                        type: 'success',
                        message: '删除成功!'
                    });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });

            }
        },

    })
</script>
</html>